package com.conan.springjdbc.dao;

import com.conan.springjdbc.bean.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

@Component
public class StudentDao implements IStudentDao {

    @Autowired
    JdbcTemplate jdbcTemplate;

    @Override
    public String insert(Student student) {
        jdbcTemplate.update("insert into student(id,name,age) values(?,?,?)",student.getId(),student.getName(),student.getAge());
        return "success";
    }

    @Override
    public String update(Student student) {
        jdbcTemplate.update("update student set id=?,name=?,age=? where id = ?",student.getId(),student.getName(),student.getAge(),student.getId());
        return "success";
    }
}
